const { MFSU } = require('@umijs/mfsu');
const webpack = require('webpack');

const mfsu = new MFSU({
  implementor: webpack,
  buildDepWithESBuild: true,
});

module.exports = {
  devServer: {
    setupMiddlewares(middlewares, devServer) {
      middlewares.unshift(...mfsu.getMiddlewares());
      return middlewares;
    },
  },
  externals: {
    react: 'React',
    'react-dom': 'ReactDOM',
    'lodash-es': 'lodash',
  },
  module: {
    rules: [
      {
        test: /\.[jt]sx?$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            plugins: [...mfsu.getBabelPlugins()],
          },
        },
      },
    ],
  }
};